<!DOCTYPE html>
<html lang="zh-cn" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>公开文章</title>
    <style type="text/css">
        @import url(https://fonts.googleapis.com/css?family=Roboto:300);

        html, body {
            margin: 0;
            padding: 0;
            width: 100%;
            height: 100%;
            background-color: #7bba58;
        }
    </style>
    <style type="text/css">
        #top-bar {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 70px;
            background-color: #FFFFFF;
            box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
        }

        #top-bar > .title {
            font-family: "Roboto", sans-serif;
            float: left;
            height: 70px;
            padding-left: 20px;
            padding-right: 20px;
            font-size: 29px;
            line-height: 70px;
            color: #7bba58;
        }

        #top-bar > .menu-button {
            font-family: "Roboto", sans-serif;
            float: left;
            color: #7bba58;
            height: 50px;
            margin-right: 10px;
            padding-right: 10px;
            padding-left: 10px;
            line-height: 50px;
            text-decoration: none;
            border-top: 10px solid #FFFFFF;
            border-bottom: 10px solid #FFFFFF;
            transition: all 0.3s ease;
        }

        #top-bar > .menu-button:hover {
            color: #43A047;
            border-bottom: 10px solid #f2f2f2;
        }

        @keyframes toActivity {
            from {
                border-bottom: 10px solid #FFFFFF;
            }
            to {
                border-bottom: 10px solid #43A047;
            }
        }

        #top-bar > .menu-button.activity {
            animation-duration: 1s;
            animation-name: toActivity;
            border-bottom: 10px solid #43A047;
        }

        #top-bar > .user-button {
            font-family: "Roboto", sans-serif;
            float: right;
            color: #7bba58;
            height: 70px;
            margin-right: 10px;
            padding-right: 10px;
            padding-left: 10px;
            line-height: 70px;
            text-decoration: none;
            transition: all 0.3s ease;
        }

        #top-bar > .user-button:hover {
            color: #43A047;
        }

        #top-bar > .exit-button {
            font-family: "Roboto", sans-serif;
            float: right;
            color: #7bba58;
            height: 70px;
            margin-right: 10px;
            padding-right: 10px;
            padding-left: 10px;
            line-height: 70px;
            text-decoration: none;
            transition: all 0.3s ease;
        }

        #top-bar > .exit-button:hover {
            color: #43A047;
        }
    </style>
    <style type="text/css">
        #main-box {
            padding-top: 70px;
            margin-right: 10%;
            margin-left: 10%;
        }
    </style>
    <style type="text/css">
        #tools-bar {
            margin: 20px;
            padding: 10px;
            background-color: #FFFFFF;
            box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
        }

        #tools-bar > form > input:not(input[type="submit"]) {
            font-family: "Roboto", sans-serif;
            outline: 0;
            background: #f2f2f2;
            width: 200px;
            border: 0;
            margin: 0 0 10px;
            padding: 10px;
            box-sizing: border-box;
            font-size: 14px;
        }

        #tools-bar > form > select {
            font-family: "Roboto", sans-serif;
            outline: 0;
            background: #f2f2f2;
            width: 200px;
            border: 0;
            margin: 0 0 10px;
            padding: 10px;
            box-sizing: border-box;
            font-size: 14px;
        }

        #tools-bar > form > input[type="submit"] {
            font-family: "Roboto", sans-serif;
            outline: 0;
            background: #4CAF50;
            width: 100px;
            border: 0;
            margin: 0 0 10px;
            padding: 10px;
            color: #FFFFFF;
            font-size: 14px;
            -webkit-transition: all 0.3s ease;
            transition: all 0.3s ease;
            cursor: pointer;
        }

        #tools-bar > form > input[type="submit"]:hover {
            background: #43A047;
        }

        #tools-bar > .button > a {
            font-family: "Roboto", sans-serif;
            outline: 0;
            background: #4CAF50;
            width: 100px;
            border: 0;
            padding: 10px;
            color: #FFFFFF;
            font-size: 14px;
            -webkit-transition: all 0.3s ease;
            transition: all 0.3s ease;
            cursor: pointer;
            display: inline-block;
            text-align: center;
            text-decoration: none;
        }

        #tools-bar > .button > a:hover {
            background: #43A047;
        }
    </style>
    <style type="text/css">
        #data-box {
            margin: 20px;
            padding: 10px;
            background-color: #FFFFFF;
            box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
        }

        #data-box > table {
            font-family: "Roboto", sans-serif;
            width: 100%;
            border-top: 1px solid #4CAF50;
            border-left: 1px solid #4CAF50;
            border-spacing: 0;
        }

        #data-box > table > thead > tr > th, #data-box > table > tbody > tr > td {
            padding: 5px;
            color: #444444;
            text-align: center;
            border-bottom: 1px solid #4CAF50;
            border-right: 1px solid #4CAF50;
        }

        #data-box > table > tbody > tr > td > a {
            color: #4CAF50;
            transition: all 0.3s ease;
        }

        #data-box > table > tbody > tr > td > a:hover {
            color: #43A047;
        }

        #data-box > .paging-box {
            text-align: center;
            padding-top: 10px;
            padding-bottom: 10px;
        }

        #data-box > .paging-box > span {
            font-family: "Roboto", sans-serif;
            display: inline-block;
            color: #717171;
            width: 80px;
            height: 30px;
            line-height: 30px;
            text-align: center;
        }

        #data-box > .paging-box > a {
            font-family: "Roboto", sans-serif;
            display: inline-block;
            color: #717171;
            background: #f2f2f2;
            width: 65px;
            height: 30px;
            font-size: 14px;
            line-height: 30px;
            text-align: center;
            text-decoration: none;
            border-radius: 5px;
            margin-left: 5px;
            margin-right: 5px;
            transition: all 0.3s ease;
        }

        #data-box > .paging-box > a:hover {
            color: #ffffff;
            background-color: #4CAF50;
        }
    </style>
    <style type="text/css">
        #popups-box {
            position: fixed;
            top: 0;
            left: 0;
            height: 100%;
            width: 100%;
            background-color: rgba(0, 0, 0, 0.3);
            z-index: 2;
        }

        #popups-box > .popups-window {
            font-family: "Roboto", sans-serif;
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background-color: #ffffff;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
        }

        #popups-box > .popups-window > .title {
            color: #FFFFFF;
            display: block;
            height: 38px;
            line-height: 38px;
            padding-left: 20px;
            font-size: 14px;
            border: 1px solid #4CAF50;
            background-color: #4CAF50;
        }

        #popups-box > .popups-window > .close {
            float: right;
            color: #FFFFFF;
            width: 40px;
            height: 40px;
            line-height: 40px;
            text-align: center;
            text-decoration: none;
        }

        #popups-box > .popups-window > .close:hover {
            color: #CCCCCC;
        }
    </style>
    <style type="text/css">
        #popups-form-box {
            position: fixed;
            top: 0;
            left: 0;
            height: 100%;
            width: 100%;
            background-color: rgba(0, 0, 0, 0.3);
            z-index: 2;
        }

        #popups-form-box > .popups-window {
            font-family: "Roboto", sans-serif;
            position: fixed;
            top: 50%;
            left: 50%;
            background-color: #ffffff;
            transform: translate(-50%, -50%);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
        }

        #popups-form-box > .popups-window > form {
            margin: 0;
            padding: 0;
        }

        #popups-form-box > .popups-window > form > .title {
            color: #FFFFFF;
            display: block;
            height: 40px;
            line-height: 40px;
            padding-left: 20px;
            font-size: 14px;
            border: 1px solid #4CAF50;
            background-color: #4CAF50;
        }

        #popups-form-box > .popups-window > form > .close {
            float: right;
            color: #FFFFFF;
            width: 40px;
            height: 40px;
            line-height: 40px;
            text-align: center;
            text-decoration: none;
        }

        #popups-form-box > .popups-window > form > .close:hover {
            color: #CCCCCC;
        }

        #popups-form-box > .popups-window > form > .button-box {
            overflow: auto;
            padding: 10px 20px;
            background-color: #4CAF50;
            border-top: 1px solid #4CAF50;
        }

        #popups-form-box > .popups-window > form > .button-box > input[type="submit"] {
            outline: 0;
            background: #4CAF50;
            width: 60px;
            border: 0;
            padding: 5px;
            color: #FFFFFF;
            font-size: 14px;
            -webkit-transition: all 0.3s ease;
            transition: all 0.3s ease;
            cursor: pointer;
        }

        #popups-form-box > .popups-window > form > .button-box > input[type="submit"]:hover {
            background: #43A047;
        }

        #popups-form-box > .popups-window > form > .button-box > a.no {
            text-align: center;
            text-decoration: none;
            float: right;
            outline: 0;
            background: #4CAF50;
            width: 50px;
            border: 0;
            padding: 5px;
            color: #FFFFFF;
            font-size: 14px;
            -webkit-transition: all 0.3s ease;
            transition: all 0.3s ease;
            cursor: pointer;
        }

        #popups-form-box > .popups-window > form > .button-box > a.no:hover {
            background-color: #43A047;
        }

        #popups-form-box > .popups-window > form > .main {
            padding: 20px 30px;
        }

        #popups-form-box > .popups-window > form > .main > table > tbody > tr > td:first-child {
            text-align: right;
        }

        #popups-form-box > .popups-window > form > .main > table > tbody > tr > td > .label {
            color: #444444;
        }

        #popups-form-box > .popups-window > form > .main > table > tbody > tr > td > input {
            outline: 0;
            background: #f2f2f2;
            width: 200px;
            height: 30px;
            border: 0;
            padding-left: 10px;
            padding-right: 10px;
            box-sizing: border-box;
            font-size: 14px;
        }

        #popups-form-box > .popups-window > form > .main > table > tbody > tr > td > select {
            outline: 0;
            background: #f2f2f2;
            width: 200px;
            height: 30px;
            border: 0;
            padding-left: 10px;
            padding-right: 10px;
            box-sizing: border-box;
            font-size: 14px;
        }

        #popups-form-box > .popups-window > form > .main > table > tbody > tr > td > textarea {
            resize: none;
            outline: 0;
            background: #f2f2f2;
            width: 200px;
            height: 100px;
            border: 0;
            padding: 10px;
            box-sizing: border-box;
            font-size: 14px;
        }
    </style>
</head>
<body>
<div id="app">
    <div id="top-bar">
        <span class="title">文章阅读网站</span>

        <a class="menu-button" href="#" th:href="@{/page/admin/novel_group_list}">分类管理</a>
        <a class="menu-button activity" href="#" th:href="@{/page/admin/novel_list}">公开文章</a>
        <a class="menu-button" href="#" th:href="@{/page/admin/novel_chapter_list}">书籍管理</a>
        <a class="menu-button" href="#" th:href="@{/page/admin/user_list}">用户管理</a>
        <a class="menu-button" href="#" th:href="@{/page/admin/comment_list}">评论管理</a>

        <a class="exit-button" href="#" th:href="@{/page/login}">退出</a>
        <a class="user-button" href="#">我的资料</a>
    </div>

    <div id="main-box">
        <div id="tools-bar">
            <form action="" method="get">
                <select name="novelGroupId">
                    <option value="0">-请选择分类-</option>
                    <option th:each="novelGroup,stats:${novelGroupList}"
                            th:selected="${novelGroup.id==novel.novelGroupId}"
                            th:text="${novelGroup.name}"
                            th:value="${novelGroup.id}">
                        暂无文章分类数据
                    </option>
                </select>
                <input autocomplete="off" name="name" placeholder="文章名称" th:value="${novel.name}" type="text">
                <input autocomplete="off" name="synopsis" placeholder="文章简介" th:value="${novel.synopsis}" type="text">
                <select name="status">
                    <option value="0">-请选择状态-</option>
                    <option th:selected="${novel.status==1}" value="1">连载中</option>
                    <option th:selected="${novel.status==2}" value="2">已完结</option>
                </select>
                <input type="submit" value="查询">
            </form>
            <div class="button">
                <a class="add" href="#">创建文章</a>
            </div>
        </div>

        <div id="data-box">
            <table>
                <thead>
                <tr>
                    <th>序号</th>
                    <th>分类</th>
                    <th>名称</th>
                    <th>简介</th>
                    <th>状态</th>
                    <th>更新时间</th>
                    <th>创建时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="novel,stats:${novelList}">
                    <td th:text="${stats.count+defaultLimit*(pageIndex -1)}">暂无序号数据</td>
                    <td th:text="${novel.novelGroup.name}">暂无分类数据</td>
                    <td th:text="${novel.name}">暂无名称数据</td>
                    <td th:text="${novel.synopsis}">暂无简介数据</td>
                    <td th:text="${novel.status==1?'连载中':(novel.status==2?'已完结':'未知')}">暂无状态数据</td>
                    <td th:text="${#dates.format(novel.updateTime,'yyyy-MM-dd HH:mm:ss')}">暂无更新时间数据</td>
                    <td th:text="${#dates.format(novel.createTime,'yyyy-MM-dd HH:mm:ss')}">暂无创建时间数据</td>
                    <td>
                        <a class="look" href="#" th:href="${novel.id}">查看</a>
                        <a class="edit" href="#" th:href="${novel.id}">编辑</a>
                        <a class="delete" href="#" th:href="${novel.id}">删除</a>
                    </td>
                </tr>
                </tbody>
            </table>

            <div class="paging-box">
                <a href="#" th:href="@{?limit={defaultLimit}&page=1(defaultLimit=${defaultLimit})}">&nbsp;最前页&nbsp;</a>
                <a href="#"
                   th:href="@{?limit={defaultLimit}&page={index}(index=${pageIndex>1?pageIndex-1:pageIndex},defaultLimit=${defaultLimit})}">&nbsp;上一页&nbsp;</a>
                <span><span th:text="${pageIndex}"></span>&nbsp;/&nbsp;<span th:text="${pageCount}"></span></span>
                <a href="#"
                   th:href="@{?limit={defaultLimit}&page={index}(index=${pageIndex<pageCount?pageIndex+1:pageIndex},defaultLimit=${defaultLimit})}">&nbsp;下一页&nbsp;</a>
                <a href="#"
                   th:href="@{?limit={defaultLimit}&page={index}(index=${pageCount},defaultLimit=${defaultLimit})}">&nbsp;最后页&nbsp;</a>
            </div>
        </div>
    </div>
</div>

<div hidden id="popups-box">
    <div class="popups-window">
        <a class="close" href="#">X</a>
        <span class="title"></span>
        <div class="main">
            <h2 style="margin-left: 20px; margin-right: 20px;color: #3a4759;">请稍后，数据加载中...</h2>
        </div>
    </div>
</div>

<div hidden id="popups-box-root"></div>

<script th:src="@{/static/js/jquery-3.6.0.js}" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        // 弹出窗口打开方法
        function openPopupsWindow(title) {
            $('#popups-box > .popups-window > .title').text(title);
            $('#popups-box > .popups-window > .close').click(function (e) {
                e.preventDefault();
                $('#popups-box').hide();
                window.location.reload();
            });
            $('#popups-box').show();
            return $('#popups-box > .popups-window > .main');
        }

        // 弹出窗口打开方法
        function openPopupsFormWindow(url) {
            $('#popups-box-root').load(url).show();
        }

        // 监听用户按钮
        $('#top-bar > .user-button').click(function (e) {
            e.preventDefault();
            openPopupsFormWindow('edit_admin');
        });

        // 监听添加按钮
        $('#tools-bar > .button > .add').click(function (e) {
            e.preventDefault();
            openPopupsFormWindow('/NovelReadingWebsite/page/admin/add_novel');
        });

        // 监听删除按钮
        $('#data-box > table > tbody > tr > td > a.delete').click(function (e) {
            e.preventDefault();
            let id = $(this).attr('href');
            openPopupsFormWindow('delete_novel/' + id);
        });

        // 监听编辑按钮
        $('#data-box > table > tbody > tr > td > a.edit').click(function (e) {
            e.preventDefault();
            let id = $(this).attr('href');
            openPopupsFormWindow('edit_novel/' + id);
        });

        // 监听查看按钮
        $('#data-box > table > tbody > tr > td > a.look').click(function (e) {
            e.preventDefault();
            let id = $(this).attr('href');
            openPopupsWindow('查看文章').load('look_novel/' + id);
        });
    });
</script>
</body>
</html>
